/*
 * ModelCC, distributed under ModelCC Shared Software License, www.modelcc.org
 */

package org.modelcc.language.syntax.builder;

import org.modelcc.language.factory.ListContent;
import org.modelcc.language.syntax.ParserMetadata;
import org.modelcc.language.syntax.Symbol;
import org.modelcc.language.syntax.SymbolBuilder;

/**
 * List element symbol builder (L ::= E) 
 * 
 * @author Fernando Berzal (berzal@acm.org)
 */
public class ListElementSymbolBuilder extends SymbolBuilder
{
	private int element;
	
	/**
	 * Constructor
	 * @param element Element index within rule RHS
	 */
	public ListElementSymbolBuilder(int element)
	{
		this.element = element;
	}

	@Override
	public boolean build(Symbol t, ParserMetadata data) 
	{
        Object[] l = new Object[1];
        l[0] = t.getContent(element).getUserData();
        t.setUserData(new ListContent(l));
        return true;
	}
}
